package com.sealer.pattern.behavioral.templatemethod;

/**
 * Created by sealer on 17/04/05.
 */
public abstract class AbstractFormat<T> implements Format<T> {
    @Override
    public void beforeFormat() {
        System.out.println("before format");
    }

    public abstract String doFormat(T t);//需要子类重写

    @Override
    public void afterFormat() {
        System.out.println("after format");
    }

    @Override
    public String format(T t) {
        beforeFormat();
        String result = doFormat(t);
        afterFormat();
        return result;
    }
}
